/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.pedagio.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author pedroo
 */
public class PersistenciaUtil {
    
    public static EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("pedagioPersistencia");

    public static EntityManager entityManager;
    
    private PersistenciaUtil() {
        //não faz nada, a classe é um singleton
    }
    
    public static EntityManager getEntityManager() {
    
           if(entityManager == null) {
               entityManager = entityManagerFactory.createEntityManager();
           }
           
           return entityManager;
    }
}
